package com.llgz.hotelmanageapi.controller;


import com.llgz.hotelmanageapi.common.CommonResult;
import com.llgz.hotelmanageapi.pojo.DO.FinancialBill;
import com.llgz.hotelmanageapi.service.impl.CheckoutInfoServiceImpl;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * <p>
 * 退房登记信息 前端控制器
 * </p>
 *
 * @author Bernie_fang
 * @since 2021-07-19
 */
@RestController
@RequestMapping("/checkoutInfo")
@RequiresRoles(value = {"root", "admin", "manager", "reception"}, logical = Logical.OR)
public class CheckoutInfoController {

    @Autowired
    private CheckoutInfoServiceImpl checkoutInfoService;

    @GetMapping("/getAllUncheckOut")
    public CommonResult getAllUncheckOut(@RequestParam(required = false) String name,
                                         @RequestParam Integer currentPage,
                                         @RequestParam Integer size){
        return checkoutInfoService.getAllUncheckOut(name,currentPage,size);
    }

    @PostMapping("/addFinancialBill")
    @Transactional
    public CommonResult addFinancialBill(@RequestBody FinancialBill financialBill) throws ParseException {
        return checkoutInfoService.addFinancialBill(financialBill);
    }


}

